package com.example.demo.lc;

import com.sun.org.apache.bcel.internal.generic.RET;

/**
 * @Description 最长递增子序列
 * @Author wzh
 * @Date 2021/10/19 2:32 下午
 * @Version 1.0
 * https://leetcode-cn.com/problems/longest-increasing-subsequence/
 */
public class Leetcode300 {
    public static void main(String[] args) {
        //int[] nums = {10,9,2,5,3,7,101,18};
        //int[] nums = {0, 1, 0, 3, 2, 3};
        int[] nums = {7,7,7,7,7,7,7};
        System.out.println(lengthOfLIS(nums));
    }

    public static int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length + 1];
        dp[0] = 1;
        int max = 1;
        for (int i = 1; i < nums.length; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            max = Math.max(dp[i], max);
        }
        return max;
    }
}
